package com.myproject.seven.src;

/**
 * @Description:类的继承
 * @Author: 2586114359
 * @date: 2024.05.18
 */
public class Transport {
    String name;
    int speed;
    void move(){
        System.out.println(name + " is moving at speed " + speed);
    }
}
//子类Car
class Car extends Transport{
    String fue1Type;

    Car(String name, int speed, String fue1Type){
        this.name = name;
        this.speed = speed;
        this.fue1Type = fue1Type;
    }
    void display (){
        System.out.println("Car fue1 type:" + fue1Type);
    }
}
//子类Bicycle
class Bicycle extends Transport{
    boolean hasGear;
    Bicycle(String name,int speed,boolean hasGear){
        this.name = name;
        this.speed = speed;
        this.hasGear = hasGear;
    }
    void display(){
        System.out.println("Bicycle has gear: " + hasGear);
    }
}
//主方法
   class main {
    public  static void main(String[] args){
        Car car = new Car("Car",100,"Petro1");
        Bicycle bicycle = new Bicycle("Bicycle",15,true);
        car.move();
        car.display();

        bicycle.move();
        bicycle.display();
    }
}
